package com.tom.service.impl;

import com.tom.constants.BaseConstants;
import com.tom.domain.Meal;
import com.tom.mapper.MealMapper;
import com.tom.service.IMealService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.time.DateUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 套餐表 服务实现类
 * </p>
 *
 * @author pengh.liu
 * @since 2021-11-22
 */
@Service
public class MealServiceImpl extends ServiceImpl<MealMapper, Meal> implements IMealService {
    @Autowired
    private MealMapper mealMapper;

    @Override
    public void saveRelationWithLogin(Long mealId, Long id) {
        if (id == null || mealId == null){
            throw new RuntimeException("LoginId为空或者mealId为空");
        }
        Date date = DateUtils.addDays(new Date(), 7);
        mealMapper.saveRelationWithLogin(mealId, date, BaseConstants.Login_Meal.MEAL_NON_PAYMENT, id);
    }
}
